﻿<Window x:Class="SaryaAccounting.Window3"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window3" Height="300" Width="300">
    <Window.Resources>
        <SolidColorBrush x:Key="LightColor" Color="#FF8ACA06" />
        <SolidColorBrush x:Key="DarkColor" Color="Green" />
        <SolidColorBrush x:Key="MainColor" Color="White" />
        <SolidColorBrush x:Key="ForegroundBrush" Color="#FF696969" />

        <Color x:Key="SelecteBackgroundColor">#5D8ACA06</Color>
        
        <Style x:Key="ModuleHeaderStyle" TargetType="{x:Type TreeViewItem}">
            <Setter Property="Background" Value="{StaticResource ResourceKey=MainColor}" />
            <Setter Property="Foreground" Value="{StaticResource ResourceKey=ForegroundBrush}" />
            <Setter Property="FontSize" Value="22" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <!--<ColumnDefinition MinWidth="19" Width="Auto" />-->
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="MouseOver" />
                                    <VisualState x:Name="Disabled" />
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="SelectionStates">
                                    <VisualState x:Name="Selected">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource ResourceKey=SelecteBackgroundColor}" />
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unselected" />
                                    <VisualState x:Name="SelectedInactive" />
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ExpansionStates">
                                    <VisualState x:Name="Expanded">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemsHost" Storyboard.TargetProperty="(UIElement.Visibility)">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="Width">
                                                <EasingDoubleKeyFrame KeyTime="00:00:0.5" Value="250" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <!--<ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                                                <EasingColorKeyFrame KeyTime="00:00:0.5" Value="#5D8ACA06" />
                                            </ColorAnimationUsingKeyFrames>-->
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Collapsed">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="Width">
                                                <EasingDoubleKeyFrame KeyTime="00:00:0.5" Value="200" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <!--<ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                                                <EasingColorKeyFrame KeyTime="00:00:0.5" Value="#FFFFFFFF" />
                                            </ColorAnimationUsingKeyFrames>-->
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>

                            <Border x:Name="Bd" Grid.Column="0" 
                                    CornerRadius="0,15,5,0" Margin="0,5,0,0" Padding="10,0,0,0" Width="200" Height="50"
                                    Background="{StaticResource MainColor}" 
                                    BorderBrush="{StaticResource LightColor}" 
                                    BorderThickness="0,5,5,5">
                                <ContentPresenter x:Name="PART_Header" ContentSource="Header" VerticalAlignment="Center" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                            </Border>
                            <ItemsPresenter x:Name="ItemsHost" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Visibility="Collapsed" />
                        </Grid>
                        
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="True">
                                <Setter TargetName="Bd" Property="Background" Value="#5D8ACA06" />
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="False" />
                                    <Condition Property="Width" Value="Auto" />
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinWidth" Value="75" />
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="False" />
                                    <Condition Property="Height" Value="Auto" />
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinHeight" Value="19" />
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <Style x:Key="ModuleItemStyle" TargetType="{x:Type TreeViewItem}">
            <Setter Property="Background" Value="{StaticResource MainColor}" />
            <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
            <Setter Property="FontSize" Value="12" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="SelectionStates">
                                    <VisualState x:Name="Selected">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource ResourceKey=SelecteBackgroundColor}" />
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unselected" />
                                    <VisualState x:Name="SelectedInactive" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="Bd" Grid.Column="0" CornerRadius="0,10,5,0" Background="{StaticResource MainColor}" 
                                    BorderBrush="{StaticResource LightColor}" BorderThickness="1" Width="175"
                                    Padding="10,2,0,2" Margin="10,2,0,0">
                                <ContentPresenter x:Name="PART_Header" ContentSource="Header" VerticalAlignment="Center" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="False" />
                                    <Condition Property="Width" Value="Auto" />
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinWidth" Value="75" />
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="False" />
                                    <Condition Property="Height" Value="Auto" />
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinHeight" Value="19" />
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="ModuleNavigatorStyle" TargetType="TreeView">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="TreeView">
                        <Border Name="Border" CornerRadius="0" BorderThickness="0">
                            <ScrollViewer Focusable="False" CanContentScroll="False" Padding="0">
                                <ItemsPresenter />
                            </ScrollViewer>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
    </Window.Resources>
    <Grid>
        <TreeView ItemsSource="{Binding}" Style="{StaticResource ModuleNavigatorStyle}">
            <TreeViewItem Header="Production" Style="{StaticResource ModuleHeaderStyle}" IsExpanded="False">
                <TreeViewItem Header="Add new Production Order..." Style="{StaticResource ModuleItemStyle}" />
                <TreeViewItem Header="Add new Warp Order..." Style="{StaticResource ModuleItemStyle}" />
                <TreeViewItem Header="Browse Production Orders" Style="{StaticResource ModuleItemStyle}" />
                <TreeViewItem Header="Browse Warp Orders" Style="{StaticResource ModuleItemStyle}" />
            </TreeViewItem>
            <TreeViewItem Header="Purchasing" Style="{StaticResource ModuleHeaderStyle}">
                <TreeViewItem Header="Browse Production Orders" Style="{StaticResource ModuleItemStyle}" />
            </TreeViewItem>
            <TreeViewItem Header="Human Resource" Style="{StaticResource ModuleHeaderStyle}">
                <TreeViewItem Header="Browse Production Orders" Style="{StaticResource ModuleItemStyle}" />
            </TreeViewItem>
        </TreeView>
    </Grid>
</Window>
